export function auth(token) {
    if (!token) {
        this.$router.push("/login")
        this.$toast.fail({
            message:"请先登录"
        })
        return false
    }
    return true
}
export function FormatTime (timestamp) {
  var date = new Date(timestamp); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
  var Y = date.getFullYear() + '-';
  var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
 
//   var h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':';
//   var m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':';
//   var s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
//   return Y + M + D + h + m + s;
  return Y+M+D
}
export function throttle(cb, wait = 1000) {
  let previous = 0;
  return (...args) => {
    const now = +new Date();
    if( now - previous > wait ){
      previous = now;
      cb.apply(this, args);
    }
  }
}